package com.sdgakj.foton.cloud.dictionary.controller;

import com.sdgakj.foton.cloud.dictionary.feign.ProvinceFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Du Ronghong
 * @Description:
 * @Date: Created in 15:32 2018/7/12
 * @Modified By:
 */
@RestController
@RequestMapping(value = "/province")
public class ApiProvinceDemoFeignController {

    @Autowired
    private ProvinceFeignClient provinceFeignClient;

    /**
     * 容错的两种实现方式之一
     * @return
     */
//    @HystrixCommand(fallbackMethod = "getProvinceListFallBack")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Object getAll() {
        return provinceFeignClient.getAll();
    }

    /**
     * 主要注意的是： 容错的方法， 参数要与请求的一致。
     * 容错返回的方法
     * @return
     */
    public String getProvinceListFallBack(){
        return "this is fallBack : " +"获取省份列表失败!";
    }

}
